package cn.credit.loan.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;

import cn.credit.loan.entity.Staging;
import cn.credit.loan.service.staging.StagingService;

/**
 * 分期期数
 * @author LI
 *
 */
@Controller
public class StagingController {
	private static Logger logger=Logger.getLogger(StagingController.class);
	@Autowired
	private StagingService stagingService;
	
	/**
	 * 分期期数列表
	 * @return
	 */
	@RequestMapping(value="/staginglist")
	@ResponseBody
	public Object list(){
		Map<String,Object> resutl=new HashMap<String,Object>();
		List<Staging> stagings= stagingService.Staginglist();
		resutl.put("stagings", stagings);
		return JSONArray.toJSONString(resutl);
	}
	
	/**
	 * 添加分期期数
	 * @param staging
	 * @return
	 */
	@RequestMapping(value="/addstaging")
	@ResponseBody
	private Object addStaging(Staging staging){
		logger.info("####------>> 进入添加分期期数");
		Map<String, Object> result=new HashMap<String, Object>();
		result.put("stag", stagingService.addByNumber(staging));
		return result;
	}
}
